package com.symone.webcms.service.impl;

import com.symone.webcms.model.JobConfig;
import com.symone.webcms.mapper.JobConfigMapper;
//import com.symone.webcms.schedule.JobFactory;
import com.symone.webcms.service.JobConfigService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 *　　
 *   @description : JobConfig 服务实现类
 *   ---------------------------------
 * 	 @author Archer Chu
 *   @since 2019-04-02
 */
@Service
public class JobConfigServiceImpl extends ServiceImpl<JobConfigMapper, JobConfig> implements JobConfigService {

    @Override
    public Page<JobConfig> findPage(Page<JobConfig> page, Wrapper<JobConfig> jobConfig) {
        List<JobConfig> result = baseMapper.selectPage(page,jobConfig);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<JobConfig> findAll() {
        Wrapper<JobConfig> ew = new EntityWrapper<JobConfig>();
        ew.where("deleted=0");
        return baseMapper.selectList(ew);
    }

    @Override
    public int delete(long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean deleteFlagById(long id) {
        return baseMapper.deleteFlagById(id);
    }

    @Override
    public int clear() {
        return baseMapper.delete(new EntityWrapper<JobConfig>().eq("deleted" ,1));
    }

    @Override
    public boolean batchUpdate(String ids, Integer status) {
        String[] idArray =  ids.split(",");
        for (String id : idArray){
            baseMapper.UpdateObject(id,status);
        }
        return true;
    }

}
